LArk.widget.bindClass(LArk.widget.BaseWidget.extend({
    options: {
        view: {
            type: "window",
            url: "view.html",
            windowOptions: {
                width: 230,
                height: 520,
            }
        }
    },
    create: function () {},
    viewWindow: null,
    winCreateOK: function (i, e) {
        this.viewWindow = e
    },
    activate: function () {
        this.createTimeLine();
        var i = this.config.data.points;
        console.log(i,'iiiii')
        if (!i || i.length < 2) {
            toastr.error("路线无坐标数据，无法漫游！")
        } else {
            var e = new LArk.FlyLine(this.viewer, this.config.data);
            this.flyLine = e, this.viewWindow.showAllInfo({
                name: e.name,
                alllen: e.alllen,
                alltime: e.alltimes
            }), this.viewer.timeline ? this.viewer.timeline.zoomTo(e.startTime, e.stopTime) : this.timeline && this.timeline.zoomTo(e.startTime, e.stopTime), e.start();
            var t = this;
            this.timetik = setInterval(function () {
                t.viewWindow.showRealTimeInfo(t.flyLine.timeinfo), t.flyLine.timeinfo && t.updateCharsWidgeFlyOk(t.flyLine.timeinfo.len)
            }, 200)
        }
    },
    disable: function () {
        this.viewWindow = null, clearInterval(this.timetik), this.flyLine.destroy(), delete this.flyLine, this.removeTimeLine()
    },
    getAttr: function () {
        return this.flyLine.options
    },
    updateStyle: function (i) {
        this.flyLine.updateStyle(i)
    },
    toRoamLine: function () {
        this.flyLine.stop(), LArk.widget.activate({
            uri: "widgets/roamLine/widget.js"
        })
    },
    charsWidgetUri: "widgets/roamChars/widget.js",
    charsCacheData: null,
    showHeightChars: function () {
        if (this.charsCacheData) {
            this.updateCharsWidge(this.charsCacheData)
        } else {
            var e = this;
            this.flyLine.getTerrainHeight(function (i) {
                e.charsCacheData = i, e.updateCharsWidge(i)
            })
        }
    },
    updateCharsWidge: function (i) {
        LArk.widget.activate({
            uri: this.charsWidgetUri,
            data: i
        })
    },
    updateCharsWidgeFlyOk: function (i) {
        var e = LArk.widget.getClass(this.charsWidgetUri);
        e && e.isActivate && e.changeFlyOk(i)
    },
    createTimeLine: function () {
        var i = this.viewer._element;
        if (!this.viewer.animation) {
            var e = document.createElement("div");
            e.className = "cesium-viewer-animationContainer", i.appendChild(e);
            var t = new Cesium.Animation(e, new Cesium.AnimationViewModel(this.viewer.clockViewModel));
            this.animation = t
        }
        if (!this.viewer.timeline) {
            var n = document.createElement("div");
            n.className = "cesium-viewer-timelineContainer", n.style.right = "0px", i.appendChild(n);
            var s = new Cesium.Timeline(n, this.viewer.clock);
            s.addEventListener("settime", this.onTimelineScrubfunction, !1), s.zoomTo(this.viewer.clock.startTime, this.viewer.clock.stopTime), this.timeline = s
        }
        this.locationOldCss = $("#location_LArkgis_jwd").css(["left", "bottom"]), $("#location_LArkgis_jwd").css({
            left: "170px",
            bottom: "25px"
        }), this.legendOldCss = $(".distance-legend").css(["left", "bottom"]), $(".distance-legend").css({
            left: "150px",
            bottom: "25px"
        })
    },
    onTimelineScrubfunction: function (i) {
        var e = i.clock;
        e.currentTime = i.timeJulian, e.shouldAnimate = !1
    },
    removeTimeLine: function () {
        this.timeline && this.timeline.removeEventListener("settime", this.onTimelineScrubfunction, !1);
        try {
            var i = this.viewer._element;
            this.animation && (i.removeChild(this.animation.container), this.animation.destroy(), this.animation = null), this.timeline && (i.removeChild(this.timeline.container), this.timeline.destroy(), this.timeline = null), $("#location_LArkgis_jwd").css(this.locationOldCss), $(".distance-legend").css(this.legendOldCss)
        } catch (i) {
            console.log(i)
        }
    }
}));